void main() {
  /**
 * Dart 数据类型 - SET 
 * 1. Set是一个无序的,元素唯一的集合
 * 2. Set有字面量和构造函数两种声明方式(字面量中用大括号)
 * 3. 无法通过下标取值
 * 4. 具有集合特性的操做
 *    1. 交集(&)
 *    2. 并集(|)
 *    3. 差集(-)
 */
  // 常量定义
  var set1 = <int>{0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
  print('set1: $set1');

  var set2 = new Set<int>();
  set2.add(1);
  set2.add(2);
  set2.add(3);
  set2.add(4);
  set2.add(4);
  print('set2: $set2');

  // list转set
  List lit1 = [1, 2, 3, 4, 5, 6, 7, 8, 9];
  print('list to set: ${Set.from(lit1)}');
  print('list to set: ${lit1.toSet()}');

  // set转list
  print('set2 to list: ${set2.toList()}');
  print('set2 to list: ${List.from(set2)}');

  // 求差集
  print('set1 - set2: ${set1.difference(set2)}');
  print('set2 - set1: ${set2.difference(set1)}');

  // 求交集
  print('set1 & set2: ${set1.intersection(set2)}');

  // 求并集
  print('set1 | set2: ${set1.union(set2)}');

  // 集合中的第一个元素
  print('set1 first: ${set1.first}');

  // 集合中的最后一个元素
  print('set1 last: ${set1.last}');

}
